import 'package:flutter/material.dart';
import 'package:flutter3x/route/route.dart';
import 'package:flutter3x/demo/layout_demo.dart';
import 'package:flutter3x/demo/sliver_demo.dart';
import 'package:get/get.dart';
import './demo/darawer_demo.dart';
import './demo/bottom_navigation_bar_demo.dart';
import './demo/listview_demo.dart';
import './demo/basic_demo.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

void main(List<String> args) => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      localizationsDelegates: const [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: const [Locale("en"), Locale("zh")],
      debugShowCheckedModeBanner: false,
      // home: const NavigatorDemo(),
      // initialRoute: '/',
      // routes: {
      //   '/':(context) => const Home(),
      //   '/newsname':(context) => const Pages(title: '新路由',),
      //   '/from':(context) => const FormDemo(),
      //   '/clockscreen':(context) => const ClockScreen(),
      //   '/mdc':(context) => const MaterialComponents(),
      // },
      getPages: RouteConfig.getPages,
      theme: ThemeData(
        primarySwatch: Colors.lightBlue,
        highlightColor: const Color.fromRGBO(255, 255, 255, 0.505),
        splashColor: Colors.white70,
        hintColor:const Color.fromRGBO(3, 54, 255, 1)
      ),
    );
  }
}

class Home extends StatelessWidget {
  const Home({super.key});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 4,
      child: Scaffold(
          backgroundColor: const Color.fromARGB(255, 247, 247, 247),
          appBar: AppBar(
            // ignore: avoid_unnecessary_containers
            title: Container(
              child: const FlexibleSpaceBar(
                titlePadding: EdgeInsets.all(8.0),
                centerTitle: true,
                title: Text(
                  'Hello DuDing',
                  style: TextStyle(
                    fontWeight: FontWeight.w900,
                  ),
                ),
              ),
            ),
            actions: <Widget>[
              IconButton(
                icon: const Icon(Icons.search),
                tooltip: 'Ssarch',
                onPressed: () => debugPrint('Ssarch button is pressed.'),
              ),
            ],
            elevation: 8.0,
            bottom: const TabBar(
              unselectedLabelColor: Colors.black38,
              indicatorColor: Colors.black54,
              indicatorSize: TabBarIndicatorSize.label,
              indicatorWeight: 5.0,
              tabs: <Widget>[
                Tab(
                  icon: Icon(Icons.local_florist),
                  text: 'Home',
                ),
                Tab(
                  icon: Icon(Icons.change_history),
                  text: 'News',
                ),
                Tab(
                  icon: Icon(Icons.directions_bike),
                  text: 'Sliver',
                ),
                Tab(
                  icon: Icon(Icons.view_quilt),
                  text: 'Layout',
                ),
              ],
            ),
          ),
          body: TabBarView(
            children: <Widget>[
              const ListViewDemo(),
              BasicDemo(),
              const LayoutDemo(),
              const SliverDemo(),
              // Icon(
              //   Icons.local_florist,
              //   size: 128.0,
              //   color: Color.fromARGB(31, 33, 16, 220),
              // ),
              // Icon(
              //   Icons.change_history,
              //   size: 128.0,
              //   color: Color.fromARGB(31, 33, 16, 220),
              // ),
              // const Icon(
              //   Icons.directions_bike,
              //   size: 128.0,
              //   color: Color.fromARGB(31, 33, 16, 220),
              // ),
            ]
          ),
          drawer: const DarawerDemo(),
          bottomNavigationBar: const BottomNavigationBarDemo(),
        ),
    );
  }
}
